package com.struct.graph.room
{
	import com.collection.DataWorkerCollection;
	import com.component.Component;
	import com.component.button.Button;
	import com.utils.Utils;
	
	import data.UserData;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.utils.Dictionary;
	
	public class RoomFrame extends Component
	{
		private var map:Bitmap;//地图
		public var btnSubmit:Button;//开始游戏
		public function RoomFrame()
		{
			super();
			
			var temp:BitmapData = new BitmapData(64, 64);
			temp.copyPixels(UserData.role, new Rectangle(0, 0, 64, 64), new Point());
			var rs:RoleShow = new RoleShow(UserData.name, temp, true);
			addChild(rs)
			var d:Dictionary = DataWorkerCollection.zip.data as Dictionary;
			var i:uint = 1;
			for(var n:String in d){
				if(n.indexOf('a') == -1){
					continue;
				}
				temp = new BitmapData(64, 64);
				temp.copyPixels(d[n], new Rectangle(0, 0, 64, 64), new Point());
				rs = new RoleShow("机器人 " + i, temp);
				rs.x = Math.floor(i%2) * (64);
				rs.y = Math.floor(i/2) * (84);
				addChild(rs)
				if(++i == 4){
					break;
				}
			}
			
			map = new Bitmap(d["map"]);
			map.width = 200;
			map.height = 150;
			map.x = 150;
			addChild(map);
			Utils.createTextField(this,150, 150, "地图大草原", 12, 0, true, TextFieldAutoSize.CENTER, 200);
			Utils.createTextField(this,150, 170, "推荐人数：4", 12, 0, true, TextFieldAutoSize.CENTER, 200);
			Utils.createTextField(this,150, 190, "回合时间：30秒", 12, 0, true, TextFieldAutoSize.CENTER, 200);
			
			btnSubmit = new Button("开始游戏");
			btnSubmit.x = 20;
			btnSubmit.y = 180;
			addChild(btnSubmit);
			x = (SSA.application.width - width) / 2;
			y = (SSA.application.height - height) / 2;
		}
	}
}